// https://www.hackerrank.com/challenges/minimum-distances#include <iostream>#define inf 9999using namespace std;int main(){    int n;    cin >> n;    int A[100001];    int a;    memset(A, -1, sizeof A);        int mx = inf;        for(int i = 1;i <= n;i++){        cin >> a;        if(A[a] == -1)            A[a]=i;        else{            mx = min(mx , i - A[a]);            A[a] = i;        }    }        if( mx != inf) cout << mx;    else cout << "-1";    return 0;}